package com.oner365.test.sql;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.oner365.test.stream.ListStreamDemo;

public class GenerateCeairSql {
  
  private static final Logger LOGGER = LoggerFactory.getLogger(ListStreamDemo.class);
  public static void main(String[] args) throws IOException {
    List<String> depSqlList = generateDepSql(60); 
    depSqlList.stream().forEach(s -> LOGGER.info("sql:{}",s));
    FileUtils.writeLines(new File("src/main/java/com/oner365/test/sql/new_dep.sql"), depSqlList);
  }
  
  //非绑定dep设备数据
  public static List<String> generateDepSql(int count) {
    List<String> depSqlList = Lists.newArrayList();
    String sqlTemplate = "INSERT INTO `mdm`.`t_apple_dep_device` (`id`, `userid`, `uuid`, `serialnumber`, `devicefamily`, `assettag`, `model`, `os`, `color`, `description`, `status`, `profileuuid`, `profileassigntime`, `profilepushtime`, `profilestatus`, `deviceassignedby`, `deviceassigneddate`, `createtime`, `updatetime`) VALUES ({id}, NULL, NULL, {serialNumber}, 'iPhone', NULL, 'iPhone 15', 'iOS', 'BLUE', 'IPHONE 15 BLUE 128GB-CHN', 1, null, null, null, null, 'muyu@nationskycom.appleid.com', '2024-05-16 16:16:02', '2024-05-07 10:54:17', '2024-05-16 16:44:24');";
    int id = 1100000000;
    String serialNumber = "J0NQJYTXV7";
    for(int i=0;i<count;i++) {
      String serial = String.valueOf(i+1);
      if(i+1 < 10) {
        serial = String.format("%02d", i+1);
      }
      depSqlList.add(sqlTemplate.replace("{id}", String.valueOf(++id)).replace("{serialNumber}","'" + serialNumber+serial+"'"));
    }
    return depSqlList;
  }

}
